package com.rh.bmw4s.view;

import android.app.Activity;
import android.net.Uri;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.lzy.imagepicker.loader.ImageLoader;
import com.rh.bmw4s.R;

import java.io.File;

/**
 * Created by Administrator on 2017/10/12.
 */

public class PicassoImageLoader implements ImageLoader {


    @Override
    public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
        Glide.with(activity)
                .load(Uri.fromFile(new File(path)))//
                .placeholder(R.mipmap.icon_placeholder)//
                .error(R.mipmap.icon_error)//
               // .override(width, height)//
                //.centerCrop()
                .diskCacheStrategy(DiskCacheStrategy.RESULT)  //只保留转换后资源
                .skipMemoryCache(true)    //跳过内存缓存
                .into(imageView);
    }

    @Override
    public void displayImagePreview(Activity activity, String path, ImageView imageView, int width, int height) {
        Glide.with(activity)
                .load(Uri.fromFile(new File(path)))//
                .placeholder(R.mipmap.icon_placeholder)//
                .error(R.mipmap.icon_error)//
               // .override(width, height)//
                //.centerCrop()
                .diskCacheStrategy(DiskCacheStrategy.RESULT)  //只保留转换后资源
                .skipMemoryCache(true)    //跳过内存缓存
                .into(imageView);
    }

    @Override
    public void clearMemoryCache() {
        //这里是清除缓存的方法,根据需要自己实现
    }
}
